//引入axios
const axios = require('axios').default
//封装实例  默认请求地址  超时时间
const instance=axios.create({
    baseURL:'http://fitness.h5.itsource.cn:3701',
    timeout:10000
})

instance.interceptors.request.use(
    config => {
      //从本地获取token[从包包里面拿到工牌]
      const token =localStorage.getItem('token')
      //把工牌挂载脖子上 [authorization 是和后端商议的]
      config.headers.authorization = token
  
      return config
    },
    err => {
      return Promise.reject(err)
    }
  )
  
  //4 响应拦截器 处理状态码
  instance.interceptors.response.use(
    response => {
      return response
    },
    err => {
      return Promise.reject(err)
    }
  )
//导出
module.exports=instance